'use client';

import { VoiceSelector } from '@/components/chat/VoiceSelector';
import { useVoice } from '@/lib/contexts/VoiceContext';

interface VoiceSettingsProps {
  className?: string;
}

export function VoiceSettings({ className = "" }: VoiceSettingsProps) {
  const { selectedVoice, setSelectedVoice } = useVoice();

  return (
    <div className={`bg-white rounded-xl border border-gray-200 p-6 ${className}`}>
      <div className="flex items-center gap-3 mb-6">
        <div className="w-10 h-10 bg-gradient-to-br from-purple-500 to-pink-600 rounded-xl flex items-center justify-center shadow-sm">
          <svg className="w-5 h-5 text-white" fill="currentColor" viewBox="0 0 20 20">
            <path fillRule="evenodd" d="M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.617.792L4.617 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.617l3.766-3.792a1 1 0 011.617.792zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z" clipRule="evenodd" />
          </svg>
        </div>
        <div>
          <h3 className="text-lg font-semibold text-gray-900">Voice Settings</h3>
          <p className="text-sm text-gray-500">Select voice for AI responses</p>
        </div>
      </div>
      
      {/* Voice selection */}
      <div className="mb-6">
        <label className="block text-sm font-semibold text-gray-700 mb-3">Voice Selection</label>
        <VoiceSelector
          selectedVoice={selectedVoice}
          onVoiceChange={setSelectedVoice}
          className="w-full"
        />
      </div>
      
      <div className="bg-gray-50 rounded-lg p-4">
        <h4 className="text-sm font-semibold text-gray-700 mb-2">Usage Instructions</h4>
        <div className="text-xs text-gray-600 space-y-1">
          <p>• Voice settings are automatically saved locally</p>
          <p>• All AI messages will use the selected voice</p>
          <p>• All voices support multilingual output</p>
          <p>• Click the play button next to AI messages to hear voice</p>
          <p>• Change voice here to update all future AI responses</p>
        </div>
      </div>
    </div>
  );
}